import axios from 'axios'
const request = axios.create({
    timeout:10000
})
request.interceptors.response.use((response:any)=>{
    return response.data.d
})
const get_url = (Obj:string,Method:string):string=>{
    //TODO 配置返回地址
    return `${Obj}/${Method}`;
}
export {
    request,
    get_url
}
export default {
    post:(Obj:string,Method:string,data:any,success:Function,error?:Function)=>{
        request.post(get_url(Obj,Method),data).then((d:any)=>{
            success(d)
        }).catch((e:any)=>{
            if(typeof error == 'function'){
                error.apply([],e)
            }
        })
    },
}